package com.tx.websocket.demo.utils;

import com.tx.websocket.demo.common.BusinessException;
import com.tx.websocket.demo.model.User;
import org.apache.shiro.SecurityUtils;

public class CommonUtils {
    public static String getStr() {
        return "hello";
    }
    
    public static Long getUserId() {
        User user = (User)SecurityUtils.getSubject().getPrincipal();

        if(user == null)
            throw new BusinessException("无登录用户");

        return user.getId();
    }
}
